package com.kws.commercial.controller;

import com.github.pagehelper.PageInfo;
import com.kws.commercial.dao.Info.QueryWorkOrderInfo;
import com.kws.commercial.dao.Rq.CreateWorkOrderRq;
import com.kws.commercial.dao.Rq.QueryWorkOrderPageRq;
import com.kws.commercial.service.CommercialWorkOrderService;
import com.kws.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>CommercialWorkOrderController</b>
 *
 * @description: CommercialWorkOrderController <br>
 * @date: 2024/10/30 16:55 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "工单管理")
@RestController
public class CommercialWorkOrderController {
    private static final Logger logger = LoggerFactory.getLogger(CommercialWorkOrderController.class);

    @Autowired
    private CommercialWorkOrderService commercialWorkOrderService;

    @ApiOperation("分页查询工单列表")
    @PostMapping("/query/workOrder/page")
    public R<PageInfo<QueryWorkOrderInfo>> queryWorkOrderPage(@RequestBody QueryWorkOrderPageRq rq){
        PageInfo<QueryWorkOrderInfo> pageInfo = commercialWorkOrderService.queryWorkOrderPage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("创建工单")
    @PostMapping("/create/workOrder")
    public R createWorkOrder(@RequestBody CreateWorkOrderRq rq){
        boolean status = commercialWorkOrderService.createWorkOrder(rq);
        return R.ok(status);
    }

    @ApiOperation("根据ID查询工单详情")
    @GetMapping("/query/workOrder/byId")
    public R<QueryWorkOrderInfo> queryWorkOrderById(@RequestParam Long id){
        QueryWorkOrderInfo info = commercialWorkOrderService.queryWorkOrderById(id);
        return R.ok(info);
    }


}
